主题
获取模型信息 - YoloGetModelInfo
函数简介
查询模型元数据与运行时状态(路径、输入尺寸、EP、类别表等)。
接口名称
YoloGetModelInfoDLL 调用
long YoloGetModelInfo(long ola, long modelHandle);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug 对象指针,由 CreateCOLAPlugInterFace 生成。 |
| modelHandle | 长整数型 | 模型句柄 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
auto info = ola.YoloGetModelInfo(modelHandle);
// info 含 TaskType、ClassNames 等csharp
using OLAPlug;
var ola = new OLAPlugServer();
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0)
{
// 模型加载失败,请检查路径与密码
}
var info = ola.YoloGetModelInfo(modelHandle);
// info 含 TaskType、ClassNames 等python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
# 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if modelHandle == 0:
# 模型加载失败,请检查路径与密码
pass
info = ola.YoloGetModelInfo(modelHandle)
# info 含 TaskType、ClassNames 等java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var info = ola.YoloGetModelInfo(modelHandle);
// info 含 TaskType、ClassNames 等cpp
var ola = com("OlaPlug.OlaSoft")
// 加载加密 YOLO 模型包
var modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var info = ola.YoloGetModelInfo(modelHandle)
// info 含 TaskType、ClassNames 等vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
If modelHandle = 0 Then
' 模型加载失败,请检查路径与密码
End If
info = ola.YoloGetModelInfo(modelHandle)
' info 含 TaskType、ClassNames 等text
.局部变量 ola, OLAPlug
ola.创建 ()
' 加载加密 YOLO 模型包
modelHandle = ola.YoloLoadModel(“models/yolov8n.olam“, “your_password“, 0)
.如果真 (modelHandle = 0)
' 模型加载失败,请检查路径与密码
.如果真结束
info = ola.YoloGetModelInfo(modelHandle)
' info 含 TaskType、ClassNames 等aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 加载加密 YOLO 模型包
var modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
var info = ola.YoloGetModelInfo(modelHandle);
// info 含 TaskType、ClassNames 等text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 加载加密 YOLO 模型包
长整数 modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0)
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
自动 info = ola.YoloGetModelInfo(modelHandle)
// info 含 TaskType、ClassNames 等cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
// 加载加密 YOLO 模型包
long modelHandle = ola.YoloLoadModel("models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
auto info = ola.YoloGetModelInfo(modelHandle);
// info 含 TaskType、ClassNames 等原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
// 加载加密 YOLO 模型包
long modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0) {
// 模型加载失败,请检查路径与密码
}
long infoJsonPtr = YoloGetModelInfo(instance, modelHandle);
if (infoJsonPtr != 0) {
char infoJson[512] = {0};
GetStringFromPtr(infoJsonPtr, infoJson, sizeof(infoJson));
FreeStringPtr(infoJsonPtr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
// 加载加密 YOLO 模型包
long modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0);
if (modelHandle == 0)
{
// 模型加载失败,请检查路径与密码
}
long infoJsonPtr = YoloGetModelInfo(instance, modelHandle);
if (infoJsonPtr != 0) {
StringBuilder infoJson = new StringBuilder(GetStringSize(infoJsonPtr) + 1);
GetStringFromPtr(infoJsonPtr, infoJson, infoJson.Capacity);
FreeStringPtr(infoJsonPtr);
string infoJsonStr = infoJson.ToString();
}python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
# 加载加密 YOLO 模型包
modelHandle = YoloLoadModel(instance, "models/yolov8n.olam", "your_password", 0)
if modelHandle == 0:
# 模型加载失败,请检查路径与密码
pass
infoJsonPtr = YoloGetModelInfo(instance, modelHandle)
if infoJsonPtr:
buf = create_string_buffer(512)
ola.GetStringFromPtr(infoJsonPtr, buf, 512)
ola.FreeStringPtr(infoJsonPtr)
infoJson = buf.value.decode("utf-8")返回值
长整数型:PascalCase JSON 字符串指针。
注意事项
- 需要插件已开通 YOLO 模块权限(Reg、Login的FeatureList中包含YOLO特性)。
- 模型元数据见 ModelInfo与ModelConfig说明。
- 不含 password、不含推理阈值。
- 返回的 JSON 字符串须调用 FreeStringPtr 释放。
